﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace Meraz.Core.Config
{
    public class UserElement : ConfigurationElement, IUser 
    {
        //First constructor
    public UserElement() { }
    //Second constructor
    public UserElement(string sectionName, string login, string password, string displayName, string email, string roles)
    {
        this.SectionName = sectionName; this.Login = login; this.Password = password; this.DisplayName = displayName; this.Email = email; this.Roles = roles;
    }

    public string SectionName { get; set; }

    //Second property: The DisplayName
    [ConfigurationProperty("roles", DefaultValue = "", IsRequired = false)]
    public string Roles
    {
        get { return (string)this["roles"]; }
        set { this["roles"] = value; }
    }
    //Second property: The DisplayName
    [ConfigurationProperty("email", DefaultValue = "", IsRequired = false)]
    public string Email
    {
        get { return (string)this["email"]; }
        set { this["email"] = value; }
    }
    //Second property: The DisplayName
    [ConfigurationProperty("displayname", DefaultValue = "Guest", IsRequired = true)]
    [StringValidator(InvalidCharacters = "|~!@#$%^&*()[]{}/;'\\", MinLength = 4)]
    public string DisplayName
    {
        get { return (string)this["displayname"]; }
        set { this["displayname"] = value; }
    }

    //Second property: The Login
    [ConfigurationProperty("login", DefaultValue = "guest", IsRequired = true, IsKey=true)]
    [StringValidator(InvalidCharacters = "|~!@#$%^&*()[]{}/;'\\", MinLength = 4)]
    public string Login
    {
        get { return (string)this["login"]; }
        set { this["login"] = value; }
    }
    //Third property: The Password
    [ConfigurationProperty("password", DefaultValue = "password", IsRequired = true)]
    [StringValidator(InvalidCharacters = "|~!@#$%^&*()[]{}/;'\\", MinLength = 6)]
    public string Password
    {
        get { return this["password"] as string; }
        set { this["password"] = value; } 
    }


    }
}
